package com.study.pre.thread;

public class Consumer extends Thread {

    private BaoZi baoZi;

    public void setBaoZi(BaoZi baoZi) {
        this.baoZi = baoZi;
    }

    @Override
    public void run() {

        while(true) {
            synchronized (baoZi) {

                if (baoZi.getStatus()) {

                    // 吃
                    baoZi.notify();

                } else {

                    //
                    try {
                        baoZi.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
